//-----------------------------------------------------------------------
// <copyright file="BannerService.cs" company="FetCo">
//     Copyright (c) FetCo. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using FetCo.Framework;
using ADESSA.Entities;
using ADESSA.Data;
    
namespace ADESSA.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class BannerService
    {
        #region Banner

        public static void CreateBanner(Banner banner)
        {            
            try
            {
                BannerDAO bannerDAO = new BannerDAO();
                bannerDAO.CreateBanner(banner);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateBannerException, ex);
            }
        }        

        public static void UpdateBanner(Banner banner)
        {            
            try
            {
                BannerDAO bannerDAO = new BannerDAO();
                bannerDAO.UpdateBanner(banner);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateBannerException, ex);
            }
        }        

        public static void DeleteBanner(long bannerId)
        {            
            try
            {
                BannerDAO bannerDAO = new BannerDAO();
                bannerDAO.DeleteBanner(bannerId);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteBannerException, ex);
            }
        }
        
        public static Banner GetBanner(long bannerId)
        {            
            try
            {
                BannerDAO bannerDAO = new BannerDAO();
                return bannerDAO.GetBanner(bannerId);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetBannerException, ex);
            }
        }                

        public static BannerCollection GetBannerList(BannerColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                BannerDAO bannerDAO = new BannerDAO();
                return bannerDAO.GetBannerList(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetBannerListException, ex);
            }
        }        

        public static BannerCollection GetBannerList(BannerColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                BannerDAO bannerDAO = new BannerDAO();
                return bannerDAO.GetBannerList(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetBannerListException, ex);
            }
        }        

	    public static BannerCollection GetBannerListByParam(object orderBy, OrderDirection orderDirection,string where)
        {            
            try
            {
                BannerDAO bannerDAO = new BannerDAO();
                return bannerDAO.GetBannerListByParam(orderBy, orderDirection,where);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetBannerListException, ex);
            }
        }        

        public static BannerCollection GetBannerListByParam(object orderBy, OrderDirection orderDirection, int page, int pageSize,string Criteria, out int totalRecords)
        {            
            try
            {
                BannerDAO bannerDAO = new BannerDAO();
                return bannerDAO.GetBannerListByParam(orderBy, orderDirection, page, pageSize,Criteria, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetBannerListException, ex);
            }
        }        

        #endregion
    }
}